import sys
from PyQt6.QtWidgets import QApplication, QMainWindow, QPushButton, QVBoxLayout, QHBoxLayout, QWidget, QTextEdit, QTableWidget, QTableWidgetItem, QDialog, QVBoxLayout, QHBoxLayout, QLabel, QSpinBox, QDialogButtonBox, QMessageBox, QSplitter
from PyQt6.QtCore import Qt
import numpy as np
import warnings
from Core import *
class InitializationDialog(QDialog):
    def __init__(self, parent=None):
        super().__init__(parent)

        #self.setWindowTitle("Initialization")
        self.setWindowTitle("初始化方案")

        # 创建布局
        layout = QVBoxLayout()

        # 功能段数量输入
        function_units_layout = QHBoxLayout()
        #function_units_label = QLabel("Number of Function Units:")
        function_units_label = QLabel("功能段数量:")
        self.num_function_units = QSpinBox()
        self.num_function_units.setMinimum(1)
        self.num_function_units.setMaximum(100)  # 可以根据需要调整最大值
        function_units_layout.addWidget(function_units_label)
        function_units_layout.addWidget(self.num_function_units)
        layout.addLayout(function_units_layout)

        # 时间列数量输入
        time_slots_layout = QHBoxLayout()
        #time_slots_label = QLabel("Number of Time Slots (T1 to Tn):")
        time_slots_label = QLabel("时间段数量(T1 to Tn):")
        self.num_time_slots = QSpinBox()
        self.num_time_slots.setMinimum(1)
        self.num_time_slots.setMaximum(100)  # 可以根据需要调整最大值
        time_slots_layout.addWidget(time_slots_label)
        time_slots_layout.addWidget(self.num_time_slots)
        layout.addLayout(time_slots_layout)

        # 确定按钮
        button_box = QDialogButtonBox(QDialogButtonBox.StandardButton.Ok | QDialogButtonBox.StandardButton.Cancel)
        button_box.accepted.connect(self.accept)
        button_box.rejected.connect(self.reject)
        # 获取按钮并设置中文文本
        ok_button = button_box.button(QDialogButtonBox.StandardButton.Ok)
        ok_button.setText("确定")

        cancel_button = button_box.button(QDialogButtonBox.StandardButton.Cancel)
        cancel_button.setText("取消")

        layout.addWidget(button_box)

        self.setLayout(layout)